Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow gpg to run factory-reset when the state is corrupted #103

Merged
merged 6 commits into from
Feb 1, 2023

Conversation

sosthene-nitrokey
Copy link
Collaborator

This PR makes some GET DATA commands return placeholder data when the state is corrupted. That way the card can still be factory reset even if the state fails to load. This avoids having to send raw commends as we recommend in the second alpha release notes.

When the state is corrupted, the card puts as a placeholder name: Card state corrupted. Factory reset recommended, so gpg --card-status looks like:

Reader ...........: Virtual PCD 00 00
Application ID ...: D2760001240103040000000000000000
Application type .: OpenPGP
Version ..........: 3.4
Manufacturer .....: test card
Serial number ....: 00000000
Name of cardholder: Card state corrupted. Factory reset recommended
Language prefs ...: [not set]
Salutation .......: 
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: rsa2048 rsa2048 rsa2048
Max. PIN lengths .: 127 127 127
PIN retry counter : 3 3 3
Signature counter : 0
KDF setting ......: off
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]
General key info..: [none]

Copy link
Member

@robin-nitrokey robin-nitrokey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

src/command/data.rs Outdated Show resolved Hide resolved
} else {
// If the state doesn't load, return placeholder so that gpg presents the option to factory reset
ctx.reply
.expand(b"Card state corrupted. Factory reset recommended")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the second sentence because I’d prefer people telling us in support if they run into this issue. We could still document it in the release notes, but if this happens in a different context, I’d like to know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I recommend them to open an issue ? The limit is 39 characters so I don't think we can put a link.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use the URL DO for that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The limit at 39 characters doesn't seem to be an issue with GPG.

@sosthene-nitrokey sosthene-nitrokey merged commit f318ed5 into main Feb 1, 2023
@sosthene-nitrokey sosthene-nitrokey deleted the corrupted-state-gpg branch February 1, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants